package com.xiao.framework.ds.autoconfigure.strategy;

import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import javax.sql.DataSource;

/**
 * @author <a href="mailto:xiaoquanidea@163.com">hutiquan</a>
 * @since 2020-02-29 1:04
 */
public class RandomDataSourceStrategy implements MultiDataSourceDetermineStrategy {

    @Override
    public DataSource determineDataSource(List<DataSource> dataSources) {
        return dataSources.get(ThreadLocalRandom.current().nextInt(dataSources.size()));
    }
}
